package com.csd.action.team;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.csd.helper.ActionResult;
import com.csd.helper.ProjectState;
import com.csd.helper.SessionManager;
import com.csd.pojo.EvaluateItem;
import com.csd.pojo.Project;
import com.csd.pojo.Score;
import com.csd.service.IEvaluateItemService;
import com.csd.service.IProjectService;
import com.csd.service.IScoreService;
import com.opensymphony.xwork2.Action;

/**
 * 
 * Action：查看项目成绩
 * 
 * @author csd
 * @version 1.0
 * 
 * <br>
 *          修订时间：2009-12-17 <br>
 *          修改原因：创建文件 <br>
 *          修改人：刘世彬
 * 
 * <br>
 * 
 */
public class ProjectScoreShowAction {

	/** 项目成绩 */
	private Score score;
	/** 项目评论 */
	private String[] words;

	private IProjectService projectService;

	private IEvaluateItemService evaluateItemService;
	public String[] getWords() {
		return words;
	}

	public void setWords(String[] words) {
		this.words = words;
	}

	public IEvaluateItemService getEvaluateItemService() {
		return evaluateItemService;
	}

	public void setEvaluateItemService(IEvaluateItemService evaluateItemService) {
		this.evaluateItemService = evaluateItemService;
	}

	public IProjectService getProjectService() {
		return projectService;
	}

	public void setProjectService(IProjectService projectService) {
		this.projectService = projectService;
	}

	public Score getScore() {
		return score;
	}

	public void setScore(Score score) {
		this.score = score;
	}

	public String execute(){
		String result = ActionResult.fail;
		
		
		List list = projectService.listTeamProject();
		if(list!=null && list.size()>0)
		{
			this.words = new String[]{"","",""};
			Project project = (Project)list.get(0);
			this.score =project.getScore();
			List<EvaluateItem> items = evaluateItemService.listEvaluateItemByProjectID(project.getId());
			int i=1;
			//把各个阶段的评论集合在一起
			for(EvaluateItem item:items){
				
				if(item.getStage().equals(ProjectState.beforeStage)){
					words[0]=words[0]+"评论"+i+":"+item.getComment()+"<br />";
					i++;}
				if(item.getStage().equals(ProjectState.middleStage)){
					words[1]=words[1]+"评论"+i+":"+item.getComment()+"<br />";	
					i++;
				}
				if(item.getStage().equals(ProjectState.afterStage)){
					words[2]=words[2]+"评论"+i+":"+item.getComment()+"<br />";	
					i++;
				}
				
			}
		}
		
		
		result = ActionResult.success;
	
		return result;
	}
}
